<template>
  <div class="wf-input">
    <i class="el-input__icon el-range__icon el-icon-time" style="line-height:20px;font-size: 14px;margin-left: -5px;" />
    {{ time | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}
  </div>

  <!-- <el-date-picker
    v-model="innerTime"
    :disabled="true"
    format="yyyy-MM-dd HH:mm"
    type="datetime"
  /> --></template>
<script>
import moment from 'moment'
export default {
  name: 'WfDateTime',
  props: {
    time: {
      type: String,
      default: null
    },
    active: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      innerTime: null
    }
  },
  watch: {
    active(newVal, oldVal) {
      if (!newVal) return
      this.getData()
    }
  },
  created() {
    if (!this.active) return
    this.getData()
  },
  methods: {
    getData() {
      setTimeout(() => {
      // todo： 从服务端获取时间
        var time = moment().format('YYYY-MM-DD HH:mm:ss')
        this.innerTime = time
        this.$emit('update:time', time)
      }, 300)
    }
  }
}
</script>
